package com.office.schedule.reminder.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.office.schedule.reminder.domain.ReminderEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.office.common.annotation.Log;
import com.office.common.core.controller.BaseController;
import com.office.common.core.domain.AjaxResult;
import com.office.common.enums.BusinessType;
import com.office.schedule.reminder.service.IReminderService;
import com.office.common.utils.poi.ExcelUtil;
import com.office.common.core.page.TableDataInfo;

/**
 * 日程提醒Controller
 *
 * @author 柒月
 * @date 2025-05-20
 */
@RestController
@RequestMapping("/situation/calendar")
public class ReminderController extends BaseController {

    @Autowired
    private IReminderService reminderService;

    /**
     * 查询日程提醒列表
     */
    @PreAuthorize("@ss.hasPermi('situation:calendar:list')")
    @GetMapping("/list")
    public TableDataInfo list(ReminderEntity reminder) {
        startPage();
        List<ReminderEntity> list = reminderService.selectReminderList(reminder);
        return getDataTable(list);
    }

    /**
     * 导出日程提醒列表
     */
    @PreAuthorize("@ss.hasPermi('situation:calendar:export')")
    @Log(title = "日程提醒", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ReminderEntity reminder) {
        List<ReminderEntity> list = reminderService.selectReminderList(reminder);
        ExcelUtil<ReminderEntity> util = new ExcelUtil<ReminderEntity>(ReminderEntity.class);
        util.exportExcel(response, list, "日程提醒数据");
    }

    /**
     * 获取日程提醒详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(reminderService.selectReminderById(id));
    }

    /**
     * 新增日程提醒
     */
    @Log(title = "日程提醒", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ReminderEntity reminder) {
        return toAjax(reminderService.insertReminder(reminder));
    }

    /**
     * 修改日程提醒
     */
    @Log(title = "日程提醒", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ReminderEntity reminder) {
        return toAjax(reminderService.updateReminder(reminder));
    }

    /**
     * 删除日程提醒
     */
    @PreAuthorize("@ss.hasPermi('situation:calendar:remove')")
    @Log(title = "日程提醒", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(reminderService.deleteReminderByIds(ids));
    }
}
